import request from '@/utils/request'
import cloudRequest from '@/utils/cloudRequest'

// 获取路由
export const getRouters = () => {
  return request({
    url: '/getRouters',
    method: 'get'
  })
}

// 云托管文件上传
export const uploadImgToCloud = (result,file) => {
  console.log(result);
  let data = new FormData();
  data.append("key", result.key);
  data.append("Signature", result.authorization);
  data.append("x-cos-security-token", result.token);
  data.append("x-cos-meta-fileid", result.cos_file_id);
  data.append("file", file);
  return cloudRequest({
    url: result.url,
    method: 'post',
    data: data
  })
}

//云托管文件预上传
export const uploadImgPre = (fileName,type) => {
  return request({
    url: "/common/uploadImg",
    method: 'post',
    data: {fileName:fileName,type:type}
  })
}